/**
 * 业务接口 -> 统计分析
 */
import { httpJ } from '../conf/index-json'
import { baseURL } from '../conf/index'
import qs from 'qs'
import store from '@/store'

/*************************************** 统计分析 *******************************************/
// 统计分析 - 列表接口
export const getInformationPublish = (params = {}) => {
	return httpJ
		.get(`${baseURL}/api/organ/information_publish/page_info`, { params })
		.then((res) => res.data)
}
// 统计分析 - 重点食材价格指数波动分析图
export const getPriceFluctuate = (params = {}) => {
	return httpJ
		.get(`${baseURL}/api/publish/getPriceFluctuate`, { params })
		.then((res) => res.data)
}
// 统计分析 - 年伙食费开支分析图
export const getShow = (params = {}) => {
	return httpJ
		.get(`${baseURL}/api/organ/information_publish/show`, { params })
		.then((res) => res.data)
}
// 统计分析 - 食物定量分析
export const getShowFoodConsume = (params = {}) => {
	return httpJ
		.get(`${baseURL}/api/organ/information_publish/show_food_consume`, {
			params
		})
		.then((res) => res.data)
}

/*************************************** 图片上传 *******************************************/

// 图片上传oss
export const uploadCropIMG = (params = {}) => {
	return httpJ
		.post(`${baseURL}/material/import_img`, params, {
			headers: { 'Content-Type': 'multipart/form-data' }
		})
		.then((res) => res.data)
}
// 图片上传oss
export const uploadIMG = (params = {}) => {
	return httpJ
		.post(`${baseURL}/material/import_img`, params, {
			headers: { 'Content-Type': 'multipart/form-data' }
		})
		.then((res) => res.data)
}
// 删除图片
export const deleteIMG = (params = {}) => {
	return httpJ
		.post(`${baseURL}/material/delete_img`, qs.stringify(params))
		.then((res) => res.data)
}

/*************************************** 能效保障 *******************************************/
// 保障评价台账 - 保障评价详情
export const evaluationDtl = (params = {}) => {
	return httpJ
		.post(`${baseURL}/api/organ/evaluation/dtl`, params)
		.then((res) => res.data)
}

// 保障评价台账 - 保障评价列表
export const evaluationPages = (params = {}) => {
	return httpJ
		.post(`${baseURL}/api/organ/evaluation/pages`, params)
		.then((res) => res.data)
}

// 保障评价台账 - 保存保障评价详情
export const evaluationSave = (params = {}) => {
	return httpJ
		.post(`${baseURL}/api/organ/evaluation/save`, params)
		.then((res) => res.data)
}

// 保障评价台账 - 保障评价下载模板
export const getApiDownloadEvaluateExcel = `${baseURL}/api/organ/evaluation/template?token=${store.state.vuex_user.token}`

// 保障评价台账 - 保障评价导入模板
export const evaluationImport = (params = {}) => {
	return httpJ
		.post(`${baseURL}/api/organ/evaluation/import`, params)
		.then((res) => res.data)
}

// 保障评价台账 - 保障评价删除
export const evaluationDelete = (params = {}) => {
	return httpJ
		.post(`${baseURL}/api/organ/evaluation/delete`, params)
		.then((res) => res.data)
}

/*************************************** 业务查询 *******************************************/
// 业务查询 - 作业规划查询
export const assignmentPlanningPages = (params = {}) => {
	return httpJ
		.post(`${baseURL}/api/cook/pc/organ/pages`, params)
		.then((res) => res.data)
}

// 食安监管 - 标准化查询数据
export const businessListSearch = (params = {}) => {
	return httpJ
		.post(`${baseURL}/api/parameter/standard_business/list`, params, {
			headers: { 'Content-Type': 'application/json' }
		})
		.then((res) => res.data)
}

// 食安监管 - 标准化修改数据
export const businessListEdit = (params = {}) => {
	return httpJ
		.post(`${baseURL}/api/parameter/standard_business/edit`, params, {
			headers: { 'Content-Type': 'application/json' }
		})
		.then((res) => res.data)
}

// 食安监管 - 标准化新增数据
export const businessListSave = (params = {}) => {
	console.log(params)
	return httpJ
		.post(`${baseURL}/api/parameter/standard_business/save`, params, {
			headers: { 'Content-Type': 'application/json' }
		})
		.then((res) => res.data)
}

// 食安监管 - 标准化删除数据
export const businessListDelete = (params = {}) => {
	return httpJ
		.post(`${baseURL}/api/parameter/standard_business/delete`, params, {
			headers: { 'Content-Type': 'application/json' }
		})
		.then((res) => res.data)
}

// 食安监管 - 标准化详情数据
export const businessListDetail = (params = {}) => {
	return httpJ
		.post(`${baseURL}/api/parameter/standard_business/get`, params, {
			headers: { 'Content-Type': 'application/json' }
		})
		.then((res) => res.data)
}

// 食安监管 -  获取消毒台账列表
export const getDisinfectAccount = (params = {}) => {
	return httpJ
		.get(`${baseURL}/api/device_all/disinfection_record/query`, { params })
		.then((res) => res.data)
}

// 获取消毒模式列表
export const getDisinfectModeList = (params = {}) => {
	return httpJ
		.get(`${baseURL}/api/device_all/disinfect_pattern/list`, { params })
		.then((res) => res.data)
}
// 留样台账列表
export const getSamplesDailyList = (params = {}) => {
	return httpJ
		.get(`${baseURL}/api/standing_fridge/pc/keep/query_list`, { params })
		.then((res) => res.data)
}

// 基础配置-食谱模板-设置默认食谱模板
export const updateFoodBookMouldCheckStatus = (params = {}) => {
	return httpJ
		.post(`${baseURL}/api/organ/updateFoodBookMouldCheckStatus`, params)
		.then((res) => res.data)
}

// 基础配置-食谱模板-删除食谱模板
export const deleteMould = (params = {}) => {
	return httpJ
		.post(`${baseURL}/api/organ/deleteMould`, params)
		.then((res) => res.data)
}

// 基础配置-配餐模式-查询食谱模板列表
export const getMouldList = (params = {}) => {
	return httpJ
		.get(`${baseURL}/api/organ/getMould`, { params })
		.then((res) => res.data)
}

// 膳食食谱制定 - 食谱生成 - ‘手工生成食谱’ - 添加菜品 - 获取菜品分类
export const selectailocaldishtype = (params = {}) => {
	return httpJ
		.get(`${baseURL}/api/organ/getDishType`, { params })
		.then((res) => res.data)
}

// 膳食食谱制定 - 食谱生成 - ‘手工生成食谱’- 添加菜品 - 根据菜品类型获取菜品
export const selectailocalfoodBydish = (params = {}) => {
	return httpJ
		.post(`${baseURL}/api/organ/dishSearchList`, params)
		.then((res) => res.data)
}

// 基础配置-食谱模板-查看食谱模板明细
export const getMouldDtl = (params = {}) => {
	return httpJ
		.post(`${baseURL}/api/organ/getMouldDtl`, params)
		.then((res) => res.data)
}

// 基础配置-食谱模板-导入食谱主模板Excel
export const importMould = (params = {}) => {
	// 文件上传
	return httpJ
		.post(`${baseURL}/api/organ/importMould`, params, {
			headers: { 'Content-Type': 'multipart/form-data' }
		})
		.then((res) => res.data)
}

// 基础配置-食谱模板-保存食谱模板
export const setMould = (params = {}) => {
	return httpJ
		.post(`${baseURL}/api/organ/setMould`, params)
		.then((res) => res.data)
}

// 基础配置-食谱模板-下载食谱主模板Excel
export const getFoodBookMould = `${baseURL}/api/organ/getFoodBookMould?token=${store.state.vuex_user.token}`

// 查询模板下发配置
export const reqUnderTemplate = (params = {}) => {
	return httpJ
		.post(`${baseURL}/api/organ/queryMouldIssueSetting`, params)
		.then((res) => res.data)
}

// 保存模板下发配置
export const saveUnderTemplate = (params = {}) => {
	return httpJ
		.post(`${baseURL}/api/organ/saveMouldBinDingUnit`, params)
		.then((res) => res.data)
}

// 下发食谱模板
export const underTemplate = (params = {}) => {
	return httpJ
		.post(`${baseURL}/api/organ/issueFoodBookMould`, params)
		.then((res) => res.data)
}

// 使用食堂食谱模板
export const useMessTemplate = (params = {}) => {
	return httpJ
		.post(`${baseURL}/api/organ/useDiningFoodBookMould`, params)
		.then((res) => res.data)
}
